<% content_for :head do %>
  <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
  <style>
      body{
          font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; font-size: 12px;
      }
      #users
      {
          font-family:"Trebuchet MS", Arial, Helvetica, sans-serif;
          width:100%;
          border-collapse:collapse;
      }
      #users td, #users th
      {
          font-size:1em;
          border:1px solid #98bf21;
          padding:3px 7px 2px 7px;
      }
      #users th
      {
          font-size:1.1em;
          text-align:left;
          padding-top:5px;
          padding-bottom:4px;
          background-color:#A7C942;
          color:#ffffff;
      }
      #users tr.alt td
      {
          color:#000000;
          background-color:#EAF2D3;
      }
      #footer { font-size:11px; color:#555555; text-align: center; }
  </style>
    <script language="JavaScript" >
        $(document).ready(function(){
           $('#weekdl').on('change', function(){
               $('#weeklink').attr('href', '/cartasur/objectives/weeklyreport?wk='+ (this.value || 1));
           });
        });
    </script>
<% end %>

<div>
  <h3><%= t 'cartasur.admin.reporting.tracksfor' %> <%= "#{(I18n.l @weekno.week.ago.beginning_of_week, format: '%B %e %l:%M %p')} - #{(I18n.l @weekno.week.ago.end_of_week, format: '%B %e %l:%M %p')}"  %></h3>

  <% if @info.size == 0 %>
      <p>
        No contributions recorded in that week.
      </p>
  <% else %>
      <table id="users" style=" font-family: 'Trebuchet MS', sans-serif; width:100%; border-collapse:collapse;">
        <tr>
          <th><%= t'cartasur.admin.reporting.user' %></th>
          <th><%= t'cartasur.admin.reporting.protocolsthisweek' %></th>
          <th><%= t'cartasur.admin.reporting.location' %></th>
        </tr>
        <% count = 0

           @info.each {| data|

             count = count + 1
        %>
            <tr style="font-size:1em; border:1px solid #98bf21; padding:3px 7px 2px 7px;<%= count.even? ? " color:#000000; background-color:#EAF2D3;" : "" %>" >
              <td>
                <%=  data[:user] %>
              </td>
              <td>
                <%= data[:protocols] %>
              </td>
              <td>
                <% data[:info].each do | info| %>
                    <a href="/cartasur/visiteds/<%= info[:visitedid] %>/summary"><%= info[:location] %>  |  <%= info[:measures].try(:to_s) << " measures" %></a> <br />
                <% end %>

              </td>
            </tr>
        <%  } %>
      </table>
  <% end %>
</div>
<br />
<div>
  <label for="weekdl"> <%= t 'cartasur.admin.reporting.selectweek' %></label>
  <select id="weekdl" >
    <% (1..15).each do |num|  %>
        <option value='<%= num %>' <%= num == @weekno ? "selected = 'selected'" : "" %>>
          <%= "#{(I18n.l num.week.ago.beginning_of_week, format: '%B %e %l:%M %p')} #{(t 'cartasur.admin.reporting.to')} #{(I18n.l num.week.ago.end_of_week, format: '%B %e %l:%M %p')}"  %>
        </option>
    <% end %>
  </select><br />

<a id='weeklink' href='/cartasur/objectives/weeklyreport?wk=1' >Click to view</a>
</div>

<hr />
<div id="footer" style="font-size:11px; color:#555555; text-align: center;">
  <p>&copy;2012-2014 <a href='<%= @url %>'>Cartasur Project</a>.</p>
</div>